package com.github.yeecode.mybatisdemo.reflect;

import com.github.yeecode.mybatisdemo.dao.UserMapper;
import com.github.yeecode.mybatisdemo.model.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.reflection.property.PropertyCopier;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Properties;

public class DemoApplicationCP2 {
    public static void main(String[] args) {


        User user = new User();
        User userCp = new User();
        userCp.setId(1234);
        userCp.setName("随意");
        MyPropertyCopier.copyBeanProperties(User.class, user, userCp);
        System.out.println(userCp.toString());

        checkIsJavaBeanStand(User.class);




    }

    public  static void checkIsJavaBeanStand(Class clazz){

        String demo = "getYouXianRen";
        System.out.println("getYouXianRen.substring(3) = " + demo.substring(3));

        Method[] methods = clazz.getDeclaredMethods();
        for (int i = 0; i < methods.length; i++) {
            boolean b = MyPropertyNamer.isProperty(methods[i].getName());
            if (b){
                System.out.println(methods[i] + " is  stand getter setter ");
                String fieldName = MyPropertyNamer.methodToProperty(methods[i].getName());
                System.out.println("fieldName = " + fieldName);
            }else{
                System.out.println(methods[i] + " is not stand getter setter ");

            }

          //  String fieldName = MyPropertyNamer.methodToProperty(methods[i].getName()); //报异常
           // System.out.println("fieldName = " + fieldName);

        }


    }




}
